package com.jugheadzhou.streamkafkaconsumer.service;

import com.jugheadzhou.core.message.CustomSink;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;

/**
 * 消息接受端，stream给我们提供了Sink,Sink源码里面是绑定input的，要跟我们配置文件的input关联的
 *
 * @author jugheadzhou
 * @date 2021-09-28
 */
@Slf4j
@EnableBinding(CustomSink.class)
public class ReceiveService {

    /**
     * 监听并接收消息
     *
     * @param payload
     */
    @StreamListener(CustomSink.INPUT)
    public void receive(Object payload){
        log.info("获得通道[{}]消息: {}", CustomSink.INPUT, payload);
    }

}
